package progress.exa4;

import java.io.DataInputStream;
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.IOException;

public class DataInputStreamStudy {

    public static void main(String[] args) throws IOException {
        dataInputStreamStudy();
    }

    public static void dataInputStreamStudy() throws IOException {
        DataInputStream dataInputStream = null;
        try{
            dataInputStream = new DataInputStream(new FileInputStream("麻子.txt"));
            StringBuilder stringBuilder = new StringBuilder();
            while (true) {
                try {
                    char n = dataInputStream.readChar();
                    stringBuilder.append(n);
                }catch (EOFException e) {
                    break;
                }
            }
            System.out.println(stringBuilder.toString());
        }catch (Exception e) {
            e.printStackTrace();
        }finally {
            if(dataInputStream!=null) {
                dataInputStream.close();
            }
        }
    }

}
